cmake_minimum_required(VERSION 3.10.0)
project(CIA2E VERSION 0.1.0)
add_compile_options(-std=c++17)
# Set build type to Debug
set(CMAKE_BUILD_TYPE Debug)

# Enable debug symbols and disable optimizations
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb")

# Enable all warnings
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic")

# # 安装cppcheck: 将编译命令导出到 compile_commands.json
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# # 安装cppcheck: 设置CPPCHECK路径
# set(CPPCHECK_EXECUTABLE "/usr/bin/cppcheck")

# 第三方依赖库的源文件和头文件均放置于 third_party/library_name  
# file(GLOB_RECURSE THIRD_PARTY_SOURCES 
#                     "${PROJECT_SOURCE_DIR}/third_party/tinyxml/*.cpp"
#                     "${PROJECT_SOURCE_DIR}/third_party/cppbase64/*.cpp")  

# 这是CIA2E的配置 收集src目录中的所有源文件
file(GLOB_RECURSE SRC_FILES "${PROJECT_SOURCE_DIR}/src/*.cpp")

# 将各个第三方依赖库的源文件（仅限有源代码的依赖库）和项目的源文件合并编译  
# set(ALL_SOURCES ${SRC_FILES} ${THIRD_PARTY_SOURCES})  

add_executable(CIA2E ${SRC_FILES} )
# add_executable(CIA2E ${ALL_SOURCES} )

# 将依赖的动态库链接到目标上
target_link_libraries(CIA2E -lpthread)

# 第三方依赖库的源文件和头文件均放置于 third_party/library_name  
# 将各个依赖库的头文件与目标关联，由于部分第三方依赖库内部依赖问题，它们的路径必须精确到library_name
target_include_directories(CIA2E PRIVATE 
                    ${PROJECT_SOURCE_DIR}/include)


set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

# # 安装cppcheck: 将cppcheck添加到编译目标之后
# add_custom_command(TARGET CIA2E POST_BUILD COMMAND ${CPPCHECK_EXECUTABLE} --project=compile_commands.json -i${PROJECT_SOURCE_DIR}/third_party 
# --enable=warning --std=c++11 --force --quiet  COMMENT "Running cppcheck after build")